package cn.pugle.ormtest.ebean.domain;

import cn.pugle.ormtest.ebean.domain.finder.OrderFinder;
import io.ebean.Model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * @author tzp
 * @date 2017/12/22
 */
@Entity
@Table(name = "st_order2")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderModel2 extends Model {
    public static final OrderFinder finder = new OrderFinder();

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    Long id;

    @Temporal(TemporalType.TIMESTAMP)
    Date orderDate;

    @Column(nullable = false)
    Long price;

    @Column(nullable = false)
    String address;

    //many to one relation

    //comment-switch-relation-1
//    @Column(name = "customer_id", nullable = false)
//    Long customerId;
//comment-switch-relation-2
    @ManyToOne
    @JoinColumn(name = "customer_id", nullable = false)
    private CustomerModel2 customer;
}
